import { Injectable } from '@angular/core';
import { Observable, Subject} from 'rxjs/Rx';
import { Device } from '../classes/Device'

@Injectable()
export class DeviceService {
  private subject = new Subject<any>();
  private deviceInfo: Device;

  constructor() { }
  sendMessage(device: Device) {
     console.log('TAG' + '---------->>>' + JSON.stringify(device));
     // 将设备信息保存在该服务的一个变量中。
     this.deviceInfo = device;
     console.log(this.deviceInfo);
     this.subject.next(device);
  }
  getDeviceInfo() {
    return this.deviceInfo;
  }
  getMessage(): Observable<any> {
    return this.subject.asObservable();
  }
}
